<?php
class Memo extends CI_Controller{
	
	function model(){
		$this->load->model('memo_m','',true);	
	}
	function index($id=null){
		$data['memo'] = $this->memo_m->memo($this->session->userdata('user_id'));
		if($id!=null):
			$data['val'] = $this->memo_m->dispSingMemo($id);
		endif;
		$data['online'] = $this->memo_m->dispLog($this->session->userdata('user_id'));
		$this->load->view('Memo_v',$data);
	}
	
	function save(){
	$now = date("Y-m-d G:i:s");
	if($this->input->post('Hmemoid') == ''):
	$data = array('memo'=>$this->input->post('Tmemo'),
					'user_id'=>$this->input->post('Huser_id'),
					'tanggal'=>$now) ;
		$this->memo_m->save($data);
	else:
	$data = array('memo'=>$this->input->post('Tmemo'),
					'user_id'=>$this->input->post('Huser_id'),
					'tanggal'=>$now) ;
		$this->memo_m->update($data,$this->input->post('Hmemoid'));
	endif;	
		redirect('memo/');
	
	}
	function edit(){
	$now = date("Y-M-d G:i:s");
	$data = array('memo'=>$this->input->post('Tmemo'),'tanggal'=>$now) ;
		$this->memo_m->save($data);
		redirect('memo/');
	}
	function del($id){
		$this->memo_m->del($id);
		redirect('memo/');
	}
}
?>